<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>组件:数据</title>
    <script src="https://cdn.bootcss.com/vue/2.4.4/vue.js"></script>

</head>
<body>
  <h3>为Vue.js组件添加数据,使组件可以动态显示各种数据(注意是数据函数,不是数据属性)</h3>
  <div id="myApp">
    <div>今天的天气是<today-weather/></div>
  </div>
  <script>
    Vue.component('today-weather',{
      template:'<strong>{{todayWeather}}</strong>',
      data:function(){
        return {
          todayWeather:'晴天'   //必须是数据函数
        }
      }
    });
    var myApp = new Vue({
      el:'#myApp',
    })
  </script>
</body>
</html>